﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace sunt.AJAX.Demo.sunt.UpdataPanel
{
    public partial class sunt_UpdataPanel_Dynamic : System.Web.UI.Page
    {
       private Label lab;
        protected void Page_PreInit(object sender, EventArgs e)
        {
            string ascx = "myUserControl.ascx";
            //this.UpdatePanel1.ContentTemplate = this.LoadComplete(ascx);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            UpdatePanel upd = new UpdatePanel();
            upd.ID = "upd1";
            Button btn = new Button();
            btn.ID = "btn1";
            btn.Text = "What Time Now?";
            btn.Click += new EventHandler(btn_Click);

            LiteralControl lit = new LiteralControl("<br/>");
            lab = new Label();
            lab.ID = "lab";
            lab.Text = "[time]";

            upd.ContentTemplateContainer.Controls.Add(btn);
            upd.ContentTemplateContainer.Controls.Add(lit);
            upd.ContentTemplateContainer.Controls.Add(lab);

            this.Form.Controls.Add(upd);
        }

        protected void btn_Click(object sender, EventArgs e)
        {
            lab.Text = DateTime.Now.ToString();
        }
    }
}